'\"macro stdmacro
.\"
.\" Copyright (c) 2022 Red Hat.  All Rights Reserved.
.\" Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
.\"
.\" This program is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License as published by the
.\" Free Software Foundation; either version 2 of the License, or (at your
.\" option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful, but
.\" WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
.\" or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
.\" for more details.
.\"
.\"
.TH PMSTORE 3 "PCP" "Performance Co-Pilot"
.SH NAME
\f3pmStore\f1 \- modify values of performance metrics
.SH "C SYNOPSIS"
.ft 3
.ad l
.hy 0
#include <pcp/pmapi.h>
.sp
int pmStore(const pmResult *\fIresult\fP);
.sp
cc ... \-lpcp
.hy
.ad
.ft 1
.SH DESCRIPTION
.de CR
.ie t \f(CR\\$1\f1\\$2
.el \fI\\$1\f1\\$2
..
In some special cases it may be helpful to modify the current values of
performance metrics,
e.g. to reset a counter to zero, or to modify a ``metric'' which is a control
variable for some agent collecting performance metrics.
.PP
.B pmStore
is a lightweight inverses of
.BR pmFetch (3).
.PP
The caller must build the
.I result
data structure (of course, this could have been returned from an earlier
.BR pmFetch (3)
call).
.PP
It is an error to pass a
.I result
to
.B pmStore
in which the
.CR numval
field within any of the
.B pmValueSet
structures has a value less than one.
.PP
The current
Performance Metrics Application Programming Interface (PMAPI)
context must be one with a host as the source of metrics, and the
current value of the nominated metrics will be changed, i.e.
.B pmStore
cannot be used to make retrospective changes to information in either
the archives, or in the recent past for real-time sources of metrics.
.PP
The return code from
.B pmStore
is zero for success.
.SH DIAGNOSTICS
.IP \f3PM_ERR_GENERIC\f1
At least one of the modifications was rejected.
No other status is available from below the PMAPI (this is the
lightweight part of the functionality!).
In cases where the outcome of storing into individual metrics is
important, the caller should make one call to either
.B pmStore
for each metric.
On the other hand, a bulk modification can be performed in a
single call for situations in which the outcome is not critical.
.IP \f3PM_ERR_NOTHOST\f1
The current PMAPI context is an archive rather than a host, or it
is a host that is not set to the current time, i.e. has been ``rewound''
to the recent past using
.BR pmSetMode (3).
.IP \f3PM_ERR_TOOSMALL\f1
The number of metrics specified in
.I result
is less than one.
.IP \f3PM_ERR_VALUE\f1
One or more of the
.CR pmValueSet s
in
.I result
has a
.CR numval
field with a value less than one.
.SH COMPATIBILITY
Prior to PCP 7.0 the
.I timestamp
field in the \f(CRpmResult\fP struct was a \f(CRstruct timeval\fP.
To support PMAPI transition, the old interface and semantics can be
used if applications are recompiled with
.BR \-DPMAPI_VERSION=2 .
.PP
For a time in PCP 6.x there was a
routine with the same semantics as the current
.B pmStore
called
.BR pmStoreHighRes ,
and a struct with the same definition as the current
\f(CRpmResult\fP struct called
\f(CRpmResultHighRes\fP,
although both are now deprecated and compile-time support for
.B pmStoreHighRes
and
\f(CRpmResultHighRes\fP
will be removed in a future release.
.SH SEE ALSO
.BR PMAPI (3),
.BR pmFetch (3),
and
.BR pmSetMode (3).
